<?php
/**
 * Created by PhpStorm.
 * User: yuyiwen
 * Date: 2018/10/18
 * Time: 上午9:39
 */
class Human {
    public $skin ;
    public function __construct($skin)
    {
        $this->skin = $skin;
    }
    private function test ()
    {
        echo 123;
    }

    protected function eat ()
    {
        echo 'eating<br>';
    }

    public function sleep ()
    {
        echo 'sleeping<br>';
    }
}


class Stu extends Human {
    public $name;
    public $age;
    public function __construct($skin , $name = '' , $age = 0)
    {
        parent::__construct($skin);
        $this->name = $name;
        $this->age = $age;

    }

    // 覆盖父亲的eat 方法
//    protected function eat($food)
//    {
//        echo '吃'.$food.'<br>';
//    }

    // 当我们调用了不存在的方法， __call 就会被执行
//    public function __call($name, $arguments)
//    {
//        if ($name == 'eat')
//        {
//            if (count($arguments) == 0) {
//                parent::eat();
//            }else {
//                $this->eat($arguments[0]);
//            }
//        }
//    }
}


$obj = new Stu('黄色');
//$obj->eat('饭');
//$obj->test();
